import { getToken } from "@/utils";
import router from "./router";

const whiteList = ["login"];
router.beforeEach(async function (to, from, next) {
  console.log(to);
  if (whiteList.includes(to.name)) {
    next();
  } else if (!getToken()) {
    next({
      name: "login",
    });
  } else {
    next();
  }
});
router.afterEach(() => {
  window.scrollTo(0, 0);
  document.body.style.overflow = "auto";
});
